package com.test.config;

import com.test.myredis.RedisClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(RedisClient.class)
@EnableConfigurationProperties(MyRedisProperties.class)
public class MyRedisAutoConfiguration {
    @Bean
    public RedisClient redisClient(MyRedisProperties myRedisProperties) {
        RedisClient redisClient = new RedisClient(myRedisProperties.getHost(), myRedisProperties.getPort(), myRedisProperties.getPassword());
        redisClient.connect();
        return redisClient;
    }
}
